package com.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.LinkedList;
import java.util.List;

public class EmployeesDAO extends EmployeesBaseDAO {
	public List<Employee> getAllEmployees() {
		List<Employee> e = new LinkedList<Employee>();
		ResultSet rs = null;
		Connection conn = null;
		try {
			conn = getConnection();
			Statement statement = conn.createStatement();
			String query = "SELECT * FROM employees";
			rs = statement.executeQuery(query);
			while (rs.next()) {
				int employeeNumber = rs.getInt("employeeNumber");
				String firstName = rs.getString("lastName");
				String lastName = rs.getString("firstName");
				String extension = rs.getString("extension");
				String email = rs.getString("email");
				Employee employee = new Employee(employeeNumber, firstName,
						lastName, extension, email);
				e.add(employee);
			}

		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return e;
	}
}
